/**
 * 取文件内容行数
 * @param {File} result
 */
export const extractRowCount = (file) => {
  const decoder = new TextDecoder();
  let fileContent = "";
  fileContent += decoder.decode(file, { stream: true });
  const lines = fileContent.split("\n");
  return lines.length - 1;
};

// JSON导出为CSV
import { saveAs } from "file-saver";
import { Parser } from "json2csv";
const fields = [
  {
    label: "用户名",
    value: "username",
  },
  {
    label: "模块名称",
    value: "module",
  },
];
const Json2csvParser = new Parser({ fields });
const csvData = Json2csvParser.parse(dataSource);
const blob = new Blob(["\uFEFF" + csvData], {
  type: "text/plain;charset=utf-8;",
});
saveAs(blob, "操作日志信息(部分).csv");
